var app = getApp()
Page({  

  data: {
    // 是否已经获取了用户信息
    hasUserInfoProfile: false,
    userInfo: null,
    user:''
  },
  getUserInfoProfileHandler() {
    let that = this
    // 获取用户的信息
    wx.getUserProfile({
      desc: '获取您的头像和昵称',
      success: (res) => {
        that.setData({
          hasUserInfoProfile: true,
          userInfo: res.userInfo
        })
        wx.setStorageSync('username', res.userInfo)
      }
    })
  },
  onShow(){
    this.setData({userInfo:wx.getStorageSync('username')})
    if (this.data.userInfo.nickName!=null) {
      this.setData({
        hasUserInfoProfile: true
      })
    }
  },
  onLoad(){
    
  },
  exit() {
    wx.clearStorage()
    this.setData({hasUserInfoProfile:false})
  }
})
